.class Lcom/baidu/at;
.super Ljava/util/TimerTask;


# instance fields
.field final synthetic a:Lcom/baidu/as;


# direct methods
.method constructor <init>(Lcom/baidu/as;)V
    .locals 0

    iput-object p1, p0, Lcom/baidu/at;->a:Lcom/baidu/as;

    invoke-direct {p0}, Ljava/util/TimerTask;-><init>()V

    return-void
.end method


# virtual methods
.method public run()V
    .locals 7

    :try_start_0
    invoke-static {}, Landroid/os/Environment;->getExternalStorageState()Ljava/lang/String;

    move-result-object v0

    const-string v1, "AppMonitor(%s, %s) SDCARD: %s, context: %s"

    const/4 v2, 0x4

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    iget-object v4, p0, Lcom/baidu/at;->a:Lcom/baidu/as;

    invoke-static {v4}, Lcom/baidu/as;->a(Lcom/baidu/as;)Ljava/util/List;

    move-result-object v4

    invoke-interface {v4}, Ljava/util/List;->size()I

    move-result v4

    invoke-static {v4}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x1

    iget-object v4, p0, Lcom/baidu/at;->a:Lcom/baidu/as;

    invoke-static {v4}, Lcom/baidu/as;->b(Lcom/baidu/as;)Ljava/util/List;

    move-result-object v4

    invoke-interface {v4}, Ljava/util/List;->size()I

    move-result v4

    invoke-static {v4}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x2

    aput-object v0, v2, v3

    const/4 v3, 0x3

    iget-object v4, p0, Lcom/baidu/at;->a:Lcom/baidu/as;

    invoke-static {v4}, Lcom/baidu/as;->c(Lcom/baidu/as;)Ljava/lang/ref/WeakReference;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v4

    aput-object v4, v2, v3

    invoke-static {v1, v2}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Lcom/baidu/bk;->b(Ljava/lang/String;)I

    const-string v1, "mounted"

    invoke-virtual {v1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/baidu/at;->a:Lcom/baidu/as;

    invoke-static {v0}, Lcom/baidu/as;->c(Lcom/baidu/as;)Ljava/lang/ref/WeakReference;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/baidu/at;->a:Lcom/baidu/as;

    invoke-static {v0}, Lcom/baidu/as;->a(Lcom/baidu/as;)Ljava/util/List;

    move-result-object v0

    invoke-interface {v0}, Ljava/util/List;->size()I

    move-result v0

    if-nez v0, :cond_1

    iget-object v0, p0, Lcom/baidu/at;->a:Lcom/baidu/as;

    invoke-static {v0}, Lcom/baidu/as;->b(Lcom/baidu/as;)Ljava/util/List;

    move-result-object v0

    invoke-interface {v0}, Ljava/util/List;->size()I

    move-result v0

    if-nez v0, :cond_1

    :cond_0
    :goto_0
    return-void

    :cond_1
    iget-object v0, p0, Lcom/baidu/at;->a:Lcom/baidu/as;

    invoke-static {v0}, Lcom/baidu/as;->a(Lcom/baidu/as;)Ljava/util/List;

    move-result-object v0

    invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v1

    :cond_2
    :goto_1
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v0

    if-eqz v0, :cond_4

    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/baidu/bl;

    iget-object v2, p0, Lcom/baidu/at;->a:Lcom/baidu/as;

    invoke-virtual {v2, v0}, Lcom/baidu/as;->c(Lcom/baidu/bl;)Z

    move-result v2

    if-eqz v2, :cond_3

    const-string v2, "[%s] downloaded\n"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/Object;

    const/4 v4, 0x0

    invoke-interface {v0}, Lcom/baidu/bl;->f()Ljava/lang/String;

    move-result-object v5

    aput-object v5, v3, v4

    invoke-static {v2, v3}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Lcom/baidu/bk;->b(Ljava/lang/String;)I

    iget-object v2, p0, Lcom/baidu/at;->a:Lcom/baidu/as;

    invoke-virtual {v2, v0}, Lcom/baidu/as;->f(Lcom/baidu/bl;)Ljava/lang/String;

    move-result-object v2

    if-eqz v2, :cond_2

    iget-object v3, p0, Lcom/baidu/at;->a:Lcom/baidu/as;

    invoke-static {v3}, Lcom/baidu/as;->a(Lcom/baidu/as;)Ljava/util/List;

    move-result-object v3

    invoke-interface {v3, v0}, Ljava/util/List;->remove(Ljava/lang/Object;)Z

    invoke-interface {v0, v2}, Lcom/baidu/bl;->a(Ljava/lang/String;)V

    new-instance v2, Lcom/baidu/au;

    invoke-direct {v2, p0, v0}, Lcom/baidu/au;-><init>(Lcom/baidu/at;Lcom/baidu/bl;)V

    invoke-virtual {v2}, Lcom/baidu/au;->start()V

    iget-object v2, p0, Lcom/baidu/at;->a:Lcom/baidu/as;

    invoke-virtual {v2, v0}, Lcom/baidu/as;->e(Lcom/baidu/bl;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_1

    :catch_0
    move-exception v0

    invoke-static {v0}, Lcom/baidu/bk;->a(Ljava/lang/Throwable;)I

    goto :goto_0

    :cond_3
    :try_start_1
    const-string v2, "[%s] downloading\n"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/Object;

    const/4 v4, 0x0

    invoke-interface {v0}, Lcom/baidu/bl;->f()Ljava/lang/String;

    move-result-object v0

    aput-object v0, v3, v4

    invoke-static {v2, v3}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Lcom/baidu/bk;->b(Ljava/lang/String;)I

    goto :goto_1

    :cond_4
    iget-object v0, p0, Lcom/baidu/at;->a:Lcom/baidu/as;

    invoke-static {v0}, Lcom/baidu/as;->d(Lcom/baidu/as;)Landroid/content/pm/PackageManager;

    move-result-object v0

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Landroid/content/pm/PackageManager;->getInstalledPackages(I)Ljava/util/List;

    move-result-object v1

    iget-object v0, p0, Lcom/baidu/at;->a:Lcom/baidu/as;

    invoke-static {v0}, Lcom/baidu/as;->b(Lcom/baidu/as;)Ljava/util/List;

    move-result-object v0

    invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v2

    :goto_2
    invoke-interface {v2}, Ljava/util/Iterator;->hasNext()Z

    move-result v0

    if-eqz v0, :cond_0

    invoke-interface {v2}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/baidu/bl;

    iget-object v3, p0, Lcom/baidu/at;->a:Lcom/baidu/as;

    invoke-static {v3, v1, v0}, Lcom/baidu/as;->a(Lcom/baidu/as;Ljava/util/List;Lcom/baidu/bl;)Z

    move-result v3

    if-eqz v3, :cond_5

    const-string v3, "[%s %s] installed\n"

    const/4 v4, 0x2

    new-array v4, v4, [Ljava/lang/Object;

    const/4 v5, 0x0

    invoke-interface {v0}, Lcom/baidu/bl;->f()Ljava/lang/String;

    move-result-object v6

    aput-object v6, v4, v5

    const/4 v5, 0x1

    invoke-interface {v0}, Lcom/baidu/bl;->n()Ljava/lang/String;

    move-result-object v6

    aput-object v6, v4, v5

    invoke-static {v3, v4}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-static {v3}, Lcom/baidu/bk;->b(Ljava/lang/String;)I

    iget-object v3, p0, Lcom/baidu/at;->a:Lcom/baidu/as;

    invoke-static {v3}, Lcom/baidu/as;->b(Lcom/baidu/as;)Ljava/util/List;

    move-result-object v3

    invoke-interface {v3, v0}, Ljava/util/List;->remove(Ljava/lang/Object;)Z

    new-instance v3, Lcom/baidu/av;

    invoke-direct {v3, p0, v0}, Lcom/baidu/av;-><init>(Lcom/baidu/at;Lcom/baidu/bl;)V

    invoke-virtual {v3}, Lcom/baidu/av;->start()V

    goto :goto_2

    :cond_5
    const-string v3, "[%s %s] installing\n"

    const/4 v4, 0x2

    new-array v4, v4, [Ljava/lang/Object;

    const/4 v5, 0x0

    invoke-interface {v0}, Lcom/baidu/bl;->f()Ljava/lang/String;

    move-result-object v6

    aput-object v6, v4, v5

    const/4 v5, 0x1

    invoke-interface {v0}, Lcom/baidu/bl;->n()Ljava/lang/String;

    move-result-object v0

    aput-object v0, v4, v5

    invoke-static {v3, v4}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Lcom/baidu/bk;->b(Ljava/lang/String;)I
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_2
.end method
